#encoding=utf-8
import rospy
import cv2
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
import numpy as np 
import message_filters

import sys, select, termios, tty
import time

rospy.init_node("test_node")
bridge = CvBridge()

def run(data):
	img = bridge.imgmsg_to_cv2(data)
	x, y = img.shape
	print(any([str(img[i][j]) == 'nan' for i in range(x) for j in range(y)]))
	x1, x2 = img.shape
	print('{} {} {}'.format(img.shape, img[:,:x2/2].shape, img[:,x2/2+1:].shape))
	cv2.imshow('img_l', img[:,:x2/2])
	cv2.imshow('img_r', img[:,x2/2+1:])
	cv2.imshow('img', img)
	cv2.waitKey(0)
	time.sleep(2000)

if __name__ == "__main__":
	rospy.Subscriber('/camera/depth/image_raw', Image, run)
	rospy.spin()